<style scoped>
  .rj-topbar {
    height: 50px; line-height: 50px; background: #f7f7f7; text-align: center; font-size: 16px; border-bottom: 1px solid #bdbbbc; position: relative
  }
  .list {
    background: #eee;
  }
  .weui-form-preview {
    background-color: #fff;
    margin: 5px;
    border-radius: 5px;
  }
  .weui-form-preview__hd label, .weui-form-preview__hd em {
    font-size: .9em !important;
  }
  .weui_navbar_item {
    font-size: 14px;
  }
  .weui_navbar_item.weui_bar_item_on {
    color: #3cc51f;
  }
  .weui-loadmore_line .weui-loadmore__tips {
    background-color: #eee;
  }
  .list {
    overflow: auto;
  }
  .rj-cell {
    display: inline-block;
    font-size: 0;
    padding: 5px 15px;
  }
  .rj-cell.max span{
    font-size: 16px;
    padding-right: 20px;
  }
  .rj-cell.minpad{
    padding-right: 10px !important;
  }
  .rj-cell label {
    color: #333;
    font-size: 14px;
  }
  .rj-cell span {
    padding-left: 5px;
    font-size: 14px;
    color: #333;
  }
  .rj-cell.note{
    width: 100%;
  }
  .rj-cell.note label{
    float: left;
  }
  .rj-cell.note span{
    width: 80%;
    display: inline-block;
  }
  .weui-cells {
    margin-top: 0;
  }
  .rj-wrap {
    background: #eee;
    overflow:auto;overflow-x: hidden
  }
  .rj-cont {
    background: #fff;
  }
  .weui-panel {
    background: #eee;
  }
  .rj-cont-tit {
    margin: 0;
    border-radius: 0;
  }
  .weui-panel {
    margin-top: 0;
    text-align: left;
  }
  .demos-content-padded {
    padding: 15px;
  }
  .attachimg {
    /*width: 100%;*/
  }
  .tipp {
    position: absolute;top: 0px;background: rgba(255,0,0,0.5);color:#fff;display: inline-block;width: 85px;text-align: center;
  }
  .rj-cell-child-tit {
    background: #f9f9f9;
    font-size: 14px;
    padding: 5px 15px;
    border-bottom: 1px solid #eee;
  }
  .outitems {
    border-top: 1px solid #fafafa;
    background: #fafafa;
    margin-left: 10px;
  }
</style>
<template>
  <div>
    <div class="rj-wrap">
      订单详情
      <a href="javascript:;" @click="$router.back(-1)" style="position: absolute; left: 10px; top: 8px">
        <img src="@/assets/back.png" style="width: 20px" />
      </a>
    </div>
    <div class="weui-panel weui-panel_access">
      <div class="weui-panel__bd">
        <div class="weui-form-preview billitem rj-cont-tit">
          <div class="rj-cell max">
            <label>订单编号：</label>
            <span>{{sellform.sellcode}}</span>
          </div>
          <div class="rj-cell max">
            <label>申请人：</label>
            <span>{{sellform.applyname}}</span>
            <span>{{sellform.depname}}</span>
          </div>
          <div class="rj-cell max">
            <label>客户：</label>
            <span>{{sellform.customername}}</span>
            <span v-if="customer != null">{{customer.typename}}</span>
          </div>
          <div class="rj-cell max">
            <label>货品类型：</label>
            <span>{{sellform.quitSRTypeName}}</span>
          </div>
          <div class="rj-cell max">
            <label>付款方式：</label>
            <span>{{sellform.paytypename}}</span>
          </div>
          <div class="rj-cell max">
            <label>订单类型：</label>
            <span>{{sellform.flagname}}{{sellform.flag == 3 ? '[' + sellform.parentcode + ']' : ''}}</span>
          </div>
          <div class="rj-cell max">
            <label>配送方式：</label>
            <span>{{sellform.deliverytypename}}</span>
          </div>
          <div class="rj-cell max">
            <label>要求发货日期：</label>
            <span>{{sellform.senddate}}</span>
          </div>
          <div class="rj-cell max">
            <label>要求到货日期：</label>
            <span>{{sellform.arrivedate}}</span>
          </div>
          <div class="rj-cell max" v-if="sellform.settletype == 1">
            <label>订单件数：</label>
            <span>{{sellform.orderpack}}</span>
          </div>
          <div class="rj-cell max" v-if="sellform.settletype == 1 && sellform.handselcount != ''">
            <label>赠送件数：</label>
            <span>{{sellform.handselcount}}</span>
          </div>
          <div class="rj-cell max">
            <label>订单重量：</label>
            <span>{{sellform.orderweight}} 吨</span>
          </div>
          <div class="rj-cell max" v-if="sellform.handselweight != '' && sellform.handselweight != null">
            <label>赠送重量：</label>
            <span>{{sellform.handselweight}} 吨</span>
          </div>
          <div class="rj-cell max">
            <label>结算币种：</label>
            <span>{{sellform.currency == 2 ? '美元' : '人民币'}}</span>
          </div>
          <div class="rj-cell max">
            <label>状态：</label>
            <span>{{sellform.statusname}}</span>
          </div>
          <div class="rj-cell">
            <label>备注：</label>
            <span style="color: #000;">{{sellform.remarks}}</span>
          </div>
          <div class="rj-cell max">
            <label>创建时间：</label>
            <span>{{sellform.createtime}}</span>
          </div>
          <div class="rj-cell max" v-if="orderfiles.length > 0">
            <label>附件：</label>
            <a v-for="(item, index) in orderfiles" :href="item.url">
              <span>{{item.filename}}</span>
            </a>
          </div>
        </div>
      </div>
      <div class="weui-panel__hd">货运路线</div>
      <div class="weui-panel__bd">
        <div class="weui-form-preview billitem rj-cont-tit">
          <div class="rj-cell max">
            <label>发货地址：</label>
            <span>{{sellform.deliProvince + sellform.deliCity + sellform.deliDistrict + sellform.deliAddress}}</span>
          </div>
          <div class="rj-cell max">
            <label>发货联系人：</label>
            <span>{{sellform.deliContact}}</span>
            <span>{{sellform.deliContactNo}}</span>
          </div>
          <div class="rj-cell max">
            <label>收货地址：</label>
            <span>{{sellform.arriProvince + sellform.arriCity + sellform.arriDistrict + sellform.arriAddress}}</span>
          </div>
          <div class="rj-cell max">
            <label>收货联系人：</label>
            <span>{{sellform.arriContact}}</span>
            <span>{{sellform.arriContactNo}}</span>
          </div>
        </div>
      </div>
      <div class="weui-panel__hd" v-if="wlinfo1 != '' && wlinfo1.carcode != ''">陆运信息</div>
      <div class="weui-panel__bd" v-if="wlinfo1 != '' && wlinfo1.carcode != ''">
        <div class="weui-form-preview billitem rj-cont-tit">
          <div class="rj-cell max">
            <label>承运人：</label>
            <span>{{wlinfo1.carcode}}</span>
            <span>{{wlinfo1.drivername}}</span>
            <span>{{wlinfo1.driverphone}}</span>
          </div>
          <div class="rj-cell max">
            <label>物流公司：</label>
            <span>{{wlinfo1.customername}}</span>
          </div>
          <div class="rj-cell max">
            <label>车型：</label>
            <span>{{wlinfo1.carType}}</span>
          </div>
          <div class="rj-cell max">
            <label>装车时间：</label>
            <span>{{wlinfo1.loadtime}}</span>
          </div>
          <div class="rj-cell max">
            <label>卸货时间：</label>
            <span>{{wlinfo1.unloadtime}}</span>
          </div>
        </div>
      </div>
      <div class="weui-panel__hd" v-if="wlinfo2 != ''">海运信息</div>
      <div class="weui-panel__bd" v-if="wlinfo2 != ''">
        <div class="weui-form-preview billitem rj-cont-tit">
          <div class="rj-cell max" v-show="wlinfo2.customername != ''">
            <label>物流公司：</label>
            <span>{{wlinfo2.customername}}</span>
          </div>
          <div class="rj-cell max" v-show="sellform.transTypeName != ''">
            <label>运输方式：</label>
            <span>{{sellform.transTypeName}}</span>
          </div>
          <div class="rj-cell max" v-show="wlinfo2.containerNo != ''">
            <label>货柜号：</label>
            <span>{{wlinfo2.containerNo}}</span>
          </div>
          <div class="rj-cell max" v-show="wlinfo2.deliPort != ''">
            <label>发货港口：</label>
            <span>{{wlinfo2.deliPort}}</span>
          </div>
          <div class="rj-cell max" v-show="wlinfo2.arriPort != ''">
            <label>收货港口：</label>
            <span>{{wlinfo2.arriPort}}</span>
          </div>
          <div class="rj-cell max" v-show="wlinfo2.arriPortCountry != ''">
            <label>收货港所属国家：</label>
            <span>{{wlinfo2.arriPortCountry}}</span>
          </div>
          <div class="rj-cell max" v-show="wlinfo2.environment != ''">
            <label>海运环境：</label>
            <span>{{wlinfo2.environment}}</span>
          </div>
          <div class="rj-cell max" v-show="wlinfo2.lifttypename != ''">
            <label>提单类型：</label>
            <span>{{wlinfo2.lifttypename}}</span>
          </div>
          <div class="rj-cell max" v-show="wlinfo2.transClause != ''">
            <label>贸易条款：</label>
            <span>{{wlinfo2.transClause}}</span>
          </div>
          <div class="rj-cell max" v-show="wlinfo2.shipCompany != ''">
            <label>货运船公司：</label>
            <span>{{wlinfo2.shipCompany}}</span>
          </div>
          <div class="rj-cell max" v-show="wlinfo2.shipname != ''">
            <label>船名称：</label>
            <span>{{wlinfo2.shipname}}</span>
          </div>
          <div class="rj-cell max" v-show="wlinfo2.shipCode != ''">
            <label>航次：</label>
            <span>{{wlinfo2.shipCode}}</span>
          </div>
          <div class="rj-cell max" v-show="wlinfo2.liftCode != ''">
            <label>提单号：</label>
            <span>{{wlinfo2.liftCode}}</span>
          </div>
          <div class="rj-cell max" v-show="wlinfo2.boxType != ''">
            <label>箱型：</label>
            <span>{{wlinfo2.boxType}}</span>
          </div>
          <div class="rj-cell max" v-show="wlinfo2.boxSize != ''">
            <label>箱数：</label>
            <span>{{wlinfo2.boxSize}}</span>
          </div>
          <div class="rj-cell max" v-show="wlinfo2.loadtime != ''">
            <label>开船日期：</label>
            <span>{{wlinfo2.loadtime}}</span>
          </div>
          <div class="rj-cell max" v-show="wlinfo2.boxCode != ''">
            <label>集装箱号：</label>
            <span>{{wlinfo2.boxCode}}</span>
          </div>
          <div class="rj-cell max" v-show="wlinfo2.remark != ''">
            <label>备注：</label>
            <span>{{wlinfo2.remark}}</span>
          </div>
        </div>
      </div>
      <div class="weui-panel__hd" v-if="wlinfo3 != ''">物流信息</div>
      <div class="weui-panel__bd" v-if="wlinfo3 != ''">
        <div class="weui-form-preview billitem rj-cont-tit">
          <div class="rj-cell max">
            <label>快递公司：</label>
            <span>{{wlinfo3.customername}}</span>
          </div>
        </div>
      </div>
      <div class="weui-panel__hd">货品信息</div>
      <div class="weui-panel__bd">
        <div class="weui-form-preview billitem rj-cont-tit" v-for="(item, index) in allItems" :key="item.guid">
          <div class="rj-cell-child-tit">产品明细 {{index+1}}</div>

          <div class="rj-cell max">
            <span>{{item.productname}}</span>
            <span>{{item.spname}}</span>
          </div>

          <div class="weui-panel__bd" style="padding-left: 15px;" v-if="item.sellitems != undefined">
            <div v-for="(product, index) in item.sellitems" class="weui-panel weui-panel_access" style="text-align: left;margin-top: 0;">
              <div class="weui-panel__hd">
                <span style="display: inline-block;width: 70%;color: #333;">{{product.productname}} {{product.spname}}</span>
                <span>X</span>
                <input class="weui-input outcount" style="display: inline-block;width: 8%;" type="number" readonly :value="product.packamount" >
                <span>{{product.unit}}</span>
              </div>
            </div>
          </div>
          <div class="rj-cell max" v-show="showPrice">
            <label>单价：</label>
            <span>{{item.price}} {{sellform.settletype == 1 ? packUnit(item.unit, sellform.currency) : sellform.currency == 2 ? '美元/吨' : '元/吨'}}</span>
          </div>
          <div class="rj-cell max" v-if="sellform.settletype == 1">
            <label>订单件数：</label>
            <span>{{item.orderpack}} {{item.unit}}</span>
          </div>
          <div class="rj-cell max" v-if="sellform.settletype == 1 && item.handselcount != ''">
            <label>赠送件数：</label>
            <span>{{item.handselcount}} {{item.unit}}</span>
          </div>
          <div class="rj-cell max" v-show="sellform.settletype == 2 && item.weight != undefined">
            <label>订单数量：</label>
            <span>{{item.weight}} {{item.unit}}</span>
          </div>
<!--          <div class="rj-cell max" v-if="sellform.settletype == 2 && checkNull(item.handselweight)">-->
<!--            <label>赠送数量：</label>-->
<!--            <span>{{item.handselweight}} {{item.unit}}</span>-->
<!--          </div>-->
          <div class="rj-cell">
            <label>备注信息：</label>
            <span>{{item.remark}}</span>
          </div>
          <div  v-for="(item, index) in sellitems" :key="item.guid"  v-if="sellform.status >= 60 && saladmperms == 1">
            <div class="rj-cell max">
              <label>到货数量：</label>
              <span>{{item.unloadweight}} {{item.unit}}</span>
            </div>
<!--            <div class="rj-cell max">-->
<!--              <label>包装重量：</label>-->
<!--              <span>{{item.packweight}} kg</span>-->
<!--            </div>-->
            <!--<div class="rj-cell max">
              <label>扣杂率：</label>
              <span>{{item.deductrate}}</span>
            </div>-->
          </div>
        </div>
      </div>
<!--      <div class="weui-panel__hd" v-if="hasWeightList">出库及到货信息</div>-->
      <div class="weui-panel__hd" v-if="sellform.status >= 45">出库信息</div>
      <div class="weui-panel__bd" v-if="sellform.status >= 45">
        <div class="weui-form-preview billitem rj-cont-tit">
          <template v-if="sellform.settletype == 1">
<!--            <div class="rj-cell max">-->
<!--              <label>出库件数：</label>-->
<!--              <span>{{sellform.loadcount}}</span>-->
<!--            </div>-->
<!--            <div class="rj-cell max">-->
<!--              <label>赠送件数：</label>-->
<!--              <span>{{sellform.handselcount != '' ? sellform.handselcount : ''}}</span>-->
<!--            </div>-->
            <div class="outitems">
              <div class="rj-cell" style="display: block;" v-for="(product, index) in allItems">
                <span>{{product.productname}} {{product.spname}}</span>
                <span style="float: right;" v-if="product.handselcount != ''">{{product.loadcount != '' ? product.loadcount : 0}}/{{product.handselcount != '' ? product.handselcount : 0}} {{product.unit}}</span>
                <span style="float: right;" v-else>{{product.loadcount != '' ? product.loadcount : 0}} {{product.unit}}</span>
              </div>
            </div>
          </template>
          <template v-if="sellform.settletype == 2">
            <div class="rj-cell max">
              <label>出库重量：</label>
              <span>{{sellform.loadweight}} 吨</span>
            </div>
            <div class="outitems">
              <div class="rj-cell " v-for="(product, index) in allItems">
                <span>出库：{{product.productname}} {{product.spname}}</span>
                <span style="float: right;padding-left: 5px;">{{product.loadweight != '' ? product.loadweight : 0}} {{product.unit}}</span>
              </div>
            </div>
          </template>
<!--          <div class="weui-panel__bd" style="padding-left: 15px;">-->
<!--            <div v-for="(product, index) in sellform.items">-->
<!--              <div class="weui-panel__hd">-->
<!--                <span style="display: inline-block;width: 70%;color: #333;">{{product.productname}} {{product.spname}}</span>-->
<!--                <span>{{product.loadcount + product.unit}}</span>-->
<!--              </div>-->
<!--            </div>-->
<!--          </div>-->
<!--          <div class="rj-cell max" v-if="JSON.stringify(unLoadWeightL) != '{}'">-->
<!--            <label>损耗：</label>-->
<!--            <span>{{sellform.shWeight + " 吨"}}</span>-->
<!--          </div>-->
<!--          <div class="rj-cell-child-tit" v-if="JSON.stringify(loadWeightL) != '{}'">发货过磅单</div>-->
<!--          <div class="rj-cell max" v-if="JSON.stringify(loadWeightL) != '{}'">-->
<!--            <label>净重：</label>-->
<!--            <span>{{loadWeightL.weight}} {{loadWeightL.stockunit}}</span>-->
<!--            <span>{{loadWeightL.operName}}</span>-->
<!--            <span>{{loadWeightL.createtime}}</span>-->
<!--          </div>-->
<!--          <div class="weui-media-box weui-media-box_text uploaderFiles" v-if="JSON.stringify(loadWeightL) != '{}' && loadWeightL.imgs.length > 0">-->
<!--            <p class="exp" style="font-size: 12px;color: #999;padding: 5px 0;">拉货过磅单</p>-->
<!--            <div class="exp uploaderFiles" style="display: inline-block;">-->
<!--              <img class="attachimg" style="padding-right: 5px;"  v-for="(image, index) in loadWeightL.imgs" :key="image.guid"  alt="" onerror="javascript:this.src='../../../static/image/default.png';this.onerror = null" :src="image.url + '-suolue.png'" :data-img="image.url + '.png'" />-->
<!--            </div>-->
<!--          </div>-->
<!--          <div class="weui-media-box weui-media-box_text uploaderFiles" v-if="sellform.whoutform.length >0 && sellform.whoutform[0].imgs.length > 0">-->
<!--            <p class="exp" style="font-size: 12px;color: #999;padding: 5px 0;">出库单</p>-->
<!--            <div class="exp uploaderFiles" style="display: inline-block;">-->
<!--              <img class="attachimg" style="padding-right: 5px;"  v-for="(image, index) in sellform.whoutform[0].imgs" :key="image.guid"  alt="" onerror="javascript:this.src='../../../static/image/default.png';this.onerror = null" :src="image.url + '-suolue.png'" :data-img="image.url + '.png'" />-->
<!--            </div>-->
<!--          </div>-->
<!--          <div class="rj-cell-child-tit" v-show="JSON.stringify(unLoadWeightL) != '{}'">卸货过磅单</div>-->
<!--          <div class="rj-cell max" v-show="JSON.stringify(unLoadWeightL) != '{}'">-->
<!--            <label>净重：</label>-->
<!--            <span>{{unLoadWeightL.weight}} {{unLoadWeightL.stockunit}}</span>-->
<!--            <span>{{unLoadWeightL.operName}}</span>-->
<!--            <span>{{unLoadWeightL.createtime}}</span>-->
<!--          </div>-->
<!--          <div class="weui-media-box weui-media-box_text uploaderFiles" v-if="JSON.stringify(unLoadWeightL) != '{}' && unLoadWeightL.imgs.length > 0">-->
<!--            <p class="exp" style="font-size: 12px;color: #999;padding: 5px 0;">拉货过磅单</p>-->
<!--            <div class="exp uploaderFiles" style="display: inline-block;">-->
<!--              <img class="attachimg" style="padding-right: 5px;"  v-for="(image, index) in unLoadWeightL.imgs" :key="image.guid"  alt="" onerror="javascript:this.src='../../../static/image/default.png';this.onerror = null" :src="image.url + '-suolue.png'" :data-img="image.url + '.png'" />-->
<!--            </div>-->
<!--          </div>-->
        </div>
      </div>
      <div class="weui-panel__hd" v-if="sellform.finalamount != ''">结算信息</div>
      <div class="weui-panel__bd" v-if="sellform.finalamount != ''">
        <div class="weui-form-preview billitem rj-cont-tit">
          <div class="rj-cell max">
            <label>订单金额：</label>
            <span>{{sellform.amount}}</span>
          </div>
          <div class="rj-cell max">
            <label>结算金额：</label>
            <span>{{sellform.finalamount}}</span>
          </div>
          <div class="rj-cell max">
            <label>有无折扣：</label>
            <span>{{sellform.isdiscount == 1 ? '有' : '无'}}</span>
          </div>
          <div class="rj-cell max">
            <label>折扣率：</label>
            <span>{{(toFix2(sellform.maxdeduct * 100)) + '%'}}</span>
          </div>
<!--            <div class="outitems">-->
<!--              <div class="rj-cell " v-for="(product, index) in sellitems">-->
<!--                <p>-->
<!--                  <span>{{product.productname}} {{product.spname}} {{product.price}} </span>-->
<!--                  <span style="float: right;padding-left: 5px;">{{sellform.settletype == 1 ? packUnit(product.unit, sellform.currency) : sellform.currency == 2 ? '美元/吨' : '元/吨'}}</span>-->
<!--                </p>-->
<!--                <p>-->
<!--                  <span v-if="sellform.settletype == 1">结算数量: {{product.settlecount}} {{product.unit}}</span>-->
<!--                  <span v-if="sellform.settletype == 2">结算重量: {{product.settleweight}} {{product.unit}}</span>-->
<!--                  <span style="float: right;padding-left: 5px;">结算金额: {{product.settleamount}} {{sellform.currency == 2 ? '美元' : '元'}}</span>-->
<!--                </p>-->
<!--              </div>-->
<!--            </div>-->
          <!--          <div class="weui-panel__bd" style="padding-left: 15px;">-->
          <!--            <div v-for="(product, index) in sellform.items">-->
          <!--              <div class="weui-panel__hd">-->
          <!--                <span style="display: inline-block;width: 70%;color: #333;">{{product.productname}} {{product.spname}}</span>-->
          <!--                <span>{{product.loadcount + product.unit}}</span>-->
          <!--              </div>-->
          <!--            </div>-->
          <!--          </div>-->
          <!--          <div class="rj-cell max" v-if="JSON.stringify(unLoadWeightL) != '{}'">-->
          <!--            <label>损耗：</label>-->
          <!--            <span>{{sellform.shWeight + " 吨"}}</span>-->
          <!--          </div>-->
          <!--          <div class="rj-cell-child-tit" v-if="JSON.stringify(loadWeightL) != '{}'">发货过磅单</div>-->
          <!--          <div class="rj-cell max" v-if="JSON.stringify(loadWeightL) != '{}'">-->
          <!--            <label>净重：</label>-->
          <!--            <span>{{loadWeightL.weight}} {{loadWeightL.stockunit}}</span>-->
          <!--            <span>{{loadWeightL.operName}}</span>-->
          <!--            <span>{{loadWeightL.createtime}}</span>-->
          <!--          </div>-->
          <!--          <div class="weui-media-box weui-media-box_text uploaderFiles" v-if="JSON.stringify(loadWeightL) != '{}' && loadWeightL.imgs.length > 0">-->
          <!--            <p class="exp" style="font-size: 12px;color: #999;padding: 5px 0;">拉货过磅单</p>-->
          <!--            <div class="exp uploaderFiles" style="display: inline-block;">-->
          <!--              <img class="attachimg" style="padding-right: 5px;"  v-for="(image, index) in loadWeightL.imgs" :key="image.guid"  alt="" onerror="javascript:this.src='../../../static/image/default.png';this.onerror = null" :src="image.url + '-suolue.png'" :data-img="image.url + '.png'" />-->
          <!--            </div>-->
          <!--          </div>-->
          <!--          <div class="weui-media-box weui-media-box_text uploaderFiles" v-if="sellform.whoutform.length >0 && sellform.whoutform[0].imgs.length > 0">-->
          <!--            <p class="exp" style="font-size: 12px;color: #999;padding: 5px 0;">出库单</p>-->
          <!--            <div class="exp uploaderFiles" style="display: inline-block;">-->
          <!--              <img class="attachimg" style="padding-right: 5px;"  v-for="(image, index) in sellform.whoutform[0].imgs" :key="image.guid"  alt="" onerror="javascript:this.src='../../../static/image/default.png';this.onerror = null" :src="image.url + '-suolue.png'" :data-img="image.url + '.png'" />-->
          <!--            </div>-->
          <!--          </div>-->
          <!--          <div class="rj-cell-child-tit" v-show="JSON.stringify(unLoadWeightL) != '{}'">卸货过磅单</div>-->
          <!--          <div class="rj-cell max" v-show="JSON.stringify(unLoadWeightL) != '{}'">-->
          <!--            <label>净重：</label>-->
          <!--            <span>{{unLoadWeightL.weight}} {{unLoadWeightL.stockunit}}</span>-->
          <!--            <span>{{unLoadWeightL.operName}}</span>-->
          <!--            <span>{{unLoadWeightL.createtime}}</span>-->
          <!--          </div>-->
          <!--          <div class="weui-media-box weui-media-box_text uploaderFiles" v-if="JSON.stringify(unLoadWeightL) != '{}' && unLoadWeightL.imgs.length > 0">-->
          <!--            <p class="exp" style="font-size: 12px;color: #999;padding: 5px 0;">拉货过磅单</p>-->
          <!--            <div class="exp uploaderFiles" style="display: inline-block;">-->
          <!--              <img class="attachimg" style="padding-right: 5px;"  v-for="(image, index) in unLoadWeightL.imgs" :key="image.guid"  alt="" onerror="javascript:this.src='../../../static/image/default.png';this.onerror = null" :src="image.url + '-suolue.png'" :data-img="image.url + '.png'" />-->
          <!--            </div>-->
          <!--          </div>-->
        </div>
      </div>
<!--      <div class="weui-panel__bd"     ref="qaform" v-if="qaform.qacode != '' && qaform.qacode != null">-->
<!--        <div class="weui-cells__title" style="height: 10px;line-height: 10px">质检信息</div>-->
<!--        <div class="weui-form-preview billitem rj-cont-tit">-->

<!--          <div style="border-top: 1px solid #eee;">-->
<!--            <div>-->
<!--              <div class="rj-cell max">-->
<!--                <label><span style="font-size: 14px;padding: 0;">质检单编号：</span></label>-->
<!--                <span>{{qaform.qacode}}</span>-->
<!--              </div>-->
<!--            </div>-->
<!--            <div class="rj-cell max">-->
<!--              <label>抽检数量：</label>-->
<!--              <span>{{qaform.chkpknum}} 包</span>-->
<!--              <span> {{qaform.chkwght}} Kg</span>-->

<!--              <label>合格重量：</label>-->
<!--              <span> {{qaform.okweight}} Kg</span>-->
<!--            </div>-->
<!--            <div class="rj-cell max">-->
<!--              <label>不合格重量：</label>-->
<!--              <span> {{qaform.notokweight}} Kg</span>-->
<!--              <label>不合格率：</label>-->
<!--              <span> {{qaform.unqualifiedchkrate}}%</span>-->
<!--            </div>-->
<!--            <div class="rj-cell max">-->
<!--              <label>土杂重量：</label>-->
<!--              <span> {{qaform.soilchkweight}} Kg</span>-->
<!--              <label>土杂率：</label>-->
<!--              <span> {{qaform.soilchkrate}}%</span>-->
<!--            </div>-->


<!--            <br>-->
<!--            <div class="rj-cell max">-->
<!--              <label>合格率：</label>-->
<!--              <span> {{Number((100-qaform.deductrate)).toFixed(2)}} %</span>-->
<!--            </div>-->

<!--            <div class="rj-cell max">-->
<!--              <label>质检人：</label>-->
<!--              <span>{{qaform.operatorname}}</span>-->
<!--              <label>质检时间：</label>-->
<!--              <span>{{qaform.createdate}}</span>-->
<!--            </div>-->
<!--            <div class="weui-media-box weui-media-box_text uploaderFiles" v-if="qaFormImg != undefined && qaFormImg.length > 0">-->
<!--              <p class="exp" style="font-size: 12px;color: #999;padding: 5px 0;">质检单照片</p>-->
<!--              <div class="exp uploaderFiles" style="display: inline-block;">-->
<!--                <img class="attachimg" style="padding-right: 5px;"  v-for="(image, index) in qaFormImg" :key="image.guid"  alt="" onerror="javascript:this.src='../../../static/image/default.png';this.onerror = null" :src="image.url + '-suolue.png'" :data-img="image.url + '.png'" />-->
<!--              </div>-->
<!--            </div>-->
<!--          </div>-->
<!--        </div>-->
<!--      </div>-->
      <div class="weui-panel__bd" v-if="backinfo != ''">
        <div class="weui-cells__title" style="height: 10px;line-height: 10px">退换货信息</div>
        <div class="weui-form-preview billitem rj-cont-tit">

          <div style="border-top: 1px solid #eee;">
            <div class="rj-cell max">
              <label>退货类型：</label>
              <span>{{backinfo.typename}}</span>
            </div>
            <template v-if="backinfo.type == 1">
              <div class="rj-cell max">
                <label>退款金额：</label>
                <span> {{backinfo.amount}}</span>
                <label>收款人：</label>
                <span> {{backinfo.payee}}</span>
              </div>
              <div class="rj-cell max">
                <label>开户行：</label>
                <span> {{backinfo.bank}}</span>
                <label>收款账号：</label>
                <span> {{backinfo.bankaccount}}</span>
              </div>
            </template>
            <template v-if="backinfo.type == 3">
              <div class="rj-cell max">
                <label>补货金额：</label>
                <span>{{backinfo.amount}}</span>
              </div>
              <div class="rj-cell max">
                <label>收款人：</label>
                <span>{{backinfo.customername}}</span>
              </div>
            </template>
            <div class="rj-cell max" v-if="backinfo.type == 1 || backinfo.type == 3">
              <label>付款方式：</label>
              <span>{{backinfo.paytypename}}</span>
            </div>
            <div class="rj-cell max">
              <label>状态：</label>
              <span>{{backinfo.statusname}}</span>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div id="bmlogs">
      <SalesOperationLogs2 v-if="sellform.flag == 3" :orderid="id" :srguid="sellform.storermguid" :departid="sellform.depguid"></SalesOperationLogs2>
      <SalesOperationLogs2 v-else :orderid="id" :srguid="sellform.storermguid" :departid="sellform.depguid" :sellformpid="sellform.parentguid" :sellformpcode="sellform.parentcode"></SalesOperationLogs2>
    </div>
  </div>
</template>

<script>
  import SalesOperationLogs2 from '../common/SalesOperationLogs2'

  export default {
    name: 'ViewSellform',
    data () {
      return {
        openid: localStorage.openid,//'oIuV2v77MaLCAQILhjI6h6oTWpHI',
        id: '',
        sellform: '',
        wlinfos: [],
        wlinfo: '',
        wlinfo1: '',
        wlinfo2: '',
        wlinfo3: '',
        sellitems: [],
        customer: '',
        hasWeightList: false,
        loadWeightL: {},
        unLoadWeightL: {},
        saladmperms: localStorage.getItem('saladmperms'),
        edpriceperms: localStorage.getItem('edpriceperms'),
        setlperms: localStorage.getItem('setlperms'),
        backperms: localStorage.getItem('backperms'),
        qaform:[],
        qaFormImg:[],
        orderfiles: [],
        backinfo: '',
        showPrice: false,
        allItems: ''
      }
    },
    components: {
      SalesOperationLogs2
    },
    mounted () {
      window.addEventListener('setItem', ()=> {
        this.saladmperms = localStorage.getItem('saladmperms');
        this.edpriceperms = localStorage.getItem('edpriceperms');
        this.setlperms = localStorage.getItem('setlperms');
        this.backperms = localStorage.getItem('backperms');
      })

      this.id = this.$route.query.id;
      this.getOrder(this.id);


      $('.weui-panel').on('click', '.uploaderFiles .attachimg', function () {
        var num = $(this).parent().children().not( ".exp" ).length;
        var imgArr = [];
        for (var i=0; i<num; i++) {
          imgArr.push($(this).parent().find('.attachimg').eq(i).data('img'));
        }
        var pnum = $(this).parent().find('.exp').length;
        var index = pnum > 0 ? $(this).index() - pnum : $(this).index();
        var pb = $.photoBrowser({
          items: imgArr,
          initIndex: index
        });
        pb.open();
      });
      this.getFiles();
      //获取是否显示价格权限
      this.getFlowtemp(2);
    },
    methods: {
      packUnit: function(unit, currency) {
        return unit != undefined && unit != '' ? currency == 2 ? '美元/' + unit : '元/' + unit : '';
      },
      getFiles: function() {
        let that = this;
        this.axios({
          method: 'get',
          url: '/sales/Fileinfo!getFileinfo.action',
          params: {orderid: this.id}
        }).then(response => {
          if (response.data.msg == 'success') {
            this.orderfiles = response.data.files;
          } else {
            //失败时不提示
          }
        });
      },
      getOrder: function (id) {
        let that = this;
        this.axios({
          method: 'get',
          url: '/sales/Sellform!detail.action',
          params: {orderid: id}
        }).then(response => {
          if (response.data.status == 'true') {
            let res = response.data.result;
            this.sellform = res;
            this.sellitems = res.items;
            this.allItems = this.sellform.spitems.concat(this.sellitems)
            this.customer = res.customer;
            this.wlinfo = response.data.wlinfoaddress != undefined ? response.data.wlinfoaddress : '';
            response.data.wlinfos.map(function (item) {
              if (item.transtype == 1) {
                that.wlinfo1 = item;
              } else if (item.transtype == 2) {
                that.wlinfo2 = item;
              } else if (item.transtype == 3) {
                that.wlinfo3 = item;
              }
            });
            let weightLst = res.weightlist;

            this.hasWeightList = weightLst.length > 0 ? true : false;
            /**
             2020-3-23
             liukx
             销售订单详情添加质检信息
             */
            let data = response.data;
            this.qaform = data.qaForm != null ? data.qaForm : {};
            this.qaFormImg = data.qaFormImg;

            for (let i=0; i<weightLst.length; i++) {
              switch (weightLst[i].wtype) {
                case 1:
                  this.loadWeightL = weightLst[i];
                  break;
                case 2:
                  this.unLoadWeightL = weightLst[i];
                  break;
              }
            }
            //退换货信息
            this.backinfo = res.backinfo[0] || '';
          } else if (response.data.status == 'true') {
            this.toastText(response.data.result);
          } else if (response != undefined && response.data != undefined && response.data.msg == 'sessionTimeOut') {
            //不不设置提示
          } else {
            this.toastError('系统错误');
          }
        });
      },
      status2Txt: function(param) {
        let res = '';
        switch (param) {
          case 1:
            res = '草稿';
            break;
          case 2:
            res = '内部审批';
            break;
          case 3:
            res = '土豆集审批';
            break;
          case 4:
            res = '待加工';
            break;
          case 5:
            res = '生产加工';
            break;
          case 6:
            res = '待出库';
            break;
          case 7:
            res = '已出库';
            break;
          case 8:
            res = '运输中';
            break;
          case 9:
            res = '已到货';
            break;
          case 10:
            res = '待结算';
            break;
          case 11:
            res = '已回款';
            break;
          case 0:
            res = '已作废';
            break;
        }
        return res;
      },
      openLogs: function() {
        if (this.sellform.flag == 3) {
          this.$router.push({name: 'SalesOperationLogs2', query: {orderid: this.id, srguid: this.sellform.storermguid, departid: this.sellform.depguid, sellformpid: this.sellform.parentguid, sellformpcode: this.sellform.parentcode}});
        } else {
          this.$router.push({name: 'SalesOperationLogs2', query: {orderid: this.id, srguid: this.sellform.storermguid, departid: this.sellform.depguid}});
        }
      },
      getFlowtemp: function(flowid) {
        let that = this;
        this.axios({
          method: 'get',
          url: '/sales/Flowtemp!getFlowtemp.action',
          params: {flowid: flowid}
        }).then(response => {
          if (response.data.msg == 'success') {
            // this.flowtemp = response.data.flowtemp;
            this.$store.state.permissions.forEach(item => {
              if (response.data.flowtemp.sensDataPerms.indexOf(item.permission) > -1) {
                that.showPrice = true;
              }
            })
          } else {
            //失败时不提示
          }
        });
      }
    }
  }
</script>
